1 <?php
2     include(
"../includes/config.php");
3     session_start();
4     
if(isset($_SESSION['manufacturer_login'])) {
5             $query_selectProducts =
"SELECT * FROM products,categories,unit WHERE products.pro_cat=categories.cat_id AND products.unit=unit.id ORDER BY pro_id";
6             $result_selectProducts = mysqli_query($con,$query_selectProducts);
7             
if($_SERVER['REQUEST_METHOD'] == "POST") {
8                 
if(isset($_POST['chkId'])) {
9                     $chkId = $_POST[
'chkId'];
10                     
foreach($chkId as $id) {
11                         $query_deleteProduct =
"DELETE FROM products WHERE pro_id='$id'";
12                         $result = mysqli_query($con,$query_deleteProduct);
13                     }
14                     
if(!$result) {
15                         echo
"<script> alert(\"Can not delete the product which has been order by retailer\"); </script>";
16                         header(
'Refresh:0');
17                     }
18                     
else {
19                         echo
"<script> alert(\"Products Deleted Successfully\"); </script>";
20                         header(
'Refresh:0');
21                     }
22                 }
23             }
24         }
25         
else {
26             header(
'Location:../index.php');
27         }
28 ?>
29 <!DOCTYPE html>
30 <html>
31 <head>
32     <title> View Products </title>
33     <link rel=
"stylesheet" href="../includes/main_style.css" >
34     <script language=
"JavaScript">
35     function toggle(source) {
36         checkboxes = document.getElementsByName(
'chkId[]');
37         
for(var i=0, n=checkboxes.length;i<n;i++) {
38             checkboxes[i].
checked = source.checked;
39         }
40     }
41     </script>
42 </head>
43 <body>
44     <?php
45         include(
"../includes/header.inc.php");
46         include(
"../includes/nav_manufacturer.inc.php");
47         include(
"../includes/aside_manufacturer.inc.php");
48     ?>
49     <section>
50         <h1>View Products</h1>
51         <form action=
"" method="POST" class="form">
52         <table
class="table_displayData">
53             <tr>
54                 <th> <input type=
"checkbox" onClick="toggle(this)" /> </th>
55                 <th> Code </th>
56                 <th> Name </th>
57                 <th> Price </th>
58                 <th> Unit </th>
59                 <th> Category </th>
60                 <th> Quantity </th>
61                 <th> Edit </th>
62             </tr>
63             <?php $i=
1; while($row_selectProducts = mysqli_fetch_array($result_selectProducts)) { ?>
64             <tr>
65                 <td> <input type=
"checkbox" name="chkId[]" value="<?php echo $row_selectProducts['pro_id']; ?>" /> </td>
66                 <td> <?php echo $row_selectProducts[
'pro_id']; ?> </td>
67                 <td> <?php echo $row_selectProducts[
'pro_name']; ?> </td>
68                 <td> <?php echo $row_selectProducts[
'pro_price']; ?> </td>
69                 <td> <?php echo $row_selectProducts[
'unit_name']; ?> </td>
70                 <td> <?php echo $row_selectProducts[
'cat_name']; ?> </td>
71                 <td> <?php
if($row_selectProducts['quantity'] == NULL){ echo "N/A";} else {echo $row_selectProducts['quantity'];} ?> </td>
72                 <td> <a href=
"edit_product.php?id=<?php echo $row_selectProducts['pro_id']; ?>"><img src="../images/edit.png" alt="edit" /></a> </td>
73             </tr>
74             <?php $i++; } ?>
75         </table>
76         <input type=
"submit" value="Delete" class="submit_button"/>
77         </form>
78     </section>
79     <?php
80         include(
"../includes/footer.inc.php");
81     ?>
82 </body>
83 </html>


Gõ tìm kiếm nhanh...